/*
 * Licensed Materials - Property of tenxcloud.com
 * (C) Copyright 2023 TenxCloud. All Rights Reserved.
 * 2023-02-09  @author xyinting
 */

package users

import "encoding/base64"

type UserPwdReset struct {
	UserName        string `json:"userName"`
	Phone           string `json:"phone"`
	Code            string `json:"code"`
	Password        string `json:"password,omitempty"`             // pwd must be base64 encode
	ConformPassword string `json:"conformPassword,omitempty"`      // conformpwd must be base64 encode
}

func (u *UserPwdReset) DecodeFromBase64() error {

	if u.Password != "" {
		passWord, err := base64.StdEncoding.DecodeString(u.Password)
		if err != nil {
			return err
		}
		u.Password = string(passWord)

	}

	if u.ConformPassword != "" {
		conform, err := base64.StdEncoding.DecodeString(u.ConformPassword)
		if err != nil {
			return err
		}
		u.ConformPassword = string(conform)
	}
	return nil

}

type UserPwdResetResponse struct {
	UserName string `json:"userName"`
	Phone    string `json:"phone"`
	Code     string `json:"code"`
}
